﻿/* *************************
   파일명 : error.js
   작성자 : 기술연구소
   작성일 : 2009.04.06
****************************/
document.write("<div id='___error_div' onmousemove='sldMouseMove(event)' onmousedown='sldMouseDown(event)' onmouseup='sldMouseUp(event)' style='width:630px;height:343;display:none;position:absolute;z-index:9999;'><iframe id='___error_frame' width='100%' height='100%' src='' marginwidth='0' marginheight='0' scrolling='no' frameborder='0' ></iframe></div>");


var error = new Object();
error.timeOut = 60*5*1000;	// 에러페이지 타임아웃 지정
error.handle;				// close()함수 호출시 setTimeout 함수 clear
error.hasDiv = true;
error.exe_resultObject = null;
error.pageWidth  = 630;
error.pageHeight = 343;

error.close = function() 
{
	 clearTimeout(error.handle);
	___prevent_div.style.display = "none";
	___error_div.style.display	= "none";
	error.init();
}

error.init = function()
{ 
	error.exe_resultObject  = null;
	___error_frame.errorform.txtCOMMON_RESULT_CODE.value       = "";
	___error_frame.errorform.txtCOMMON_MENU_INFO.value         = "";
	___error_frame.errorform.txtCOMMON_OP_INFO.value           = "";
	___error_frame.errorform.teaCOMMON_RESULT_MESSAGE.value    = "";
	___error_frame.errorform.txtCOMMON_CHARGE_PERSON.value     = "";
	___error_frame.errorform.txtCOMMON_ERROR_CLASS_NAME.value  = "";
	___error_frame.errorform.txtCOMMON_ERROR_LINE_NUMBER.value = "";

}

error.open = function(gridObj) 
{
	var resultObject = new Object();
	if( gridObj != null )
	{ 
		resultObject.RESULT_CODE       = gridObj.GetNodeData(iconst.RESULT_CODE);
		resultObject.MENU_INFO         = gridObj.GetNodeData(iconst.MENU_INFO);
		resultObject.OP_INFO           = gridObj.GetNodeData(iconst.OP_INFO);
		resultObject.RESULT_MSG        = gridObj.GetNodeData(iconst.RESULT_MSG);
		resultObject.CHARGE_PERSON     = gridObj.GetNodeData(iconst.CHARGE_PERSON);
		resultObject.ERROR_CLASS_NAME  = gridObj.GetNodeData(iconst.ERROR_CLASS_NAME);
		resultObject.ERROR_LINE_NUMBER = gridObj.GetNodeData(iconst.ERROR_LINE_NUMBER);
	}else{ 
		resultObject.RESULT_CODE       = iajax.getValue(iconst.RESULT_CODE);
		resultObject.MENU_INFO         = iajax.getValue(iconst.MENU_INFO);
		resultObject.OP_INFO           = iajax.getValue(iconst.OP_INFO);
		resultObject.RESULT_MSG        = iajax.getValue(iconst.RESULT_MSG);
		resultObject.CHARGE_PERSON     = iajax.getValue(iconst.CHARGE_PERSON);
		resultObject.ERROR_CLASS_NAME  = iajax.getValue(iconst.ERROR_CLASS_NAME);
		resultObject.ERROR_LINE_NUMBER = iajax.getValue(iconst.ERROR_LINE_NUMBER);
	}
	error.doOpen(resultObject);
}

error.doOpen = function(resultObject)
{
	document.all.___error_frame.src = '/resource/xml/Error.xml';	
	exe_resultObject = resultObject; 
}

error.doOpenExecute = function()
{ 
	___error_frame.errorform.txtCOMMON_RESULT_CODE.value       = exe_resultObject.RESULT_CODE;
	___error_frame.errorform.txtCOMMON_MENU_INFO.value         = exe_resultObject.MENU_INFO;
	___error_frame.errorform.txtCOMMON_OP_INFO.value           = exe_resultObject.OP_INFO;
	___error_frame.errorform.teaCOMMON_RESULT_MESSAGE.value    = exe_resultObject.RESULT_MSG;
	___error_frame.errorform.txtCOMMON_CHARGE_PERSON.value     = exe_resultObject.CHARGE_PERSON;
	___error_frame.errorform.txtCOMMON_ERROR_CLASS_NAME.value  = exe_resultObject.ERROR_CLASS_NAME;
	___error_frame.errorform.txtCOMMON_ERROR_LINE_NUMBER.value = exe_resultObject.ERROR_LINE_NUMBER;
	
	___error_frame.fnChangeImage();
	//___error_frame.errorform.txtCOMMON_DIV.value = "Y";
	//___error_frame.fnCheckDiv();
	
	windowX=(document.body.clientWidth-error.pageWidth)/2;	//가운데 띄우기위한 윈도우 x위치
	windowY=(document.body.clientHeight-error.pageHeight)/2;	//가운데 띄우기위한 윈도우 y위치
	
	error.resize(windowX,windowY); 
	___prevent_div.style.display = "";
	___error_div.style.display	= "";
	___error_div.focus();
	
	error.handle = setTimeout("error.close()",error.timeOut);
}

error.resize = function(windowX, windowY)
{ 
	//___error_div.style.width  = error.pageWidth;		//이미지 너비사이즈
	//___error_div.style.height = error.pageHeight;		//이미지 높이사이즈	
	___error_div.style.left   = windowX; 				//left 위치 설정
	___error_div.style.top    = windowY; 				//top  위치 설정
}

var doDrag = false;
var sldMouseLeft = 0;
var sldMouseTop = 0;

function sldMouseDown(e)
{
	if (!e) {e = window.event};
	doDrag = true;
	var obj = document.getElementById("___error_div");
	var sldLeft = obj.style.posLeft;
	var sldTop = obj.style.posTop;
//alert("clientY " + e.clientY + " sldTop " + sldTop + " scrollTop " + document.body.scrollTop);
	sldMouseLeft = e.clientX + document.body.scrollLeft - sldLeft;
	sldMouseTop  = e.clientY + document.body.scrollTop - sldTop;
	obj.setCapture();
}

function sldMouseUp(e)
{
	doDrag=false;
	var obj = document.getElementById("___error_div");
	obj.releaseCapture();
}

function setPosition(obj,oLeft,oTop) {
	obj.style.left = oLeft + "px";
	obj.style.top  = oTop  + "px";
}

function sldMouseMove(e)
{
	if (!e) {e = window.event;}
	if (doDrag)
	{
		obj = document.getElementById("___error_div");
		setPosition(obj,e.clientX+document.body.scrollLeft-sldMouseLeft,e.clientY+document.body.scrollTop-sldMouseTop);
		return false;
	} 
}


//var preX,preY;
//function fnMouseDown()
//{
//	var error = document.getElementById("___error_div");
//	preX = event.x-error.style.posLeft;
//	preY = event.y-error.style.posTop;
//	document.all.test111.value = "x:[" + event.x + "] y[" + event.y +"]";
////	error.setCapture();
//}
//function fnMouseUp()
//{
//	var error = document.getElementById("___error_div");
////	error.releaseCapture();
//}
//function fnMouseMove()
//{
//	var error = document.getElementById("___error_div");
//	if(event.y - preY < 0) return;
//	
//	error.style.posLeft = event.x - preX;
//	error.style.posTop = event.y - preY;
//	
//	if(document.body.clientHeight + document.body.scrollTop < error.style.posTop + error.style.pixelHeight)
//	{
//		document.body.scrollTop = error.style.posTop + error.style.pixelHeight - document.body.clientHeight;
//	}
//	else if(document.body.scrollTop > error.style.posTop)
//	{
//		document.body.scrollTop = error.style.posTop;
//	}
//}
